﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddBankStep2.aspx.cs" Inherits="YY.Web.MyAgent.financial_information.AddBank.AddBankStep2" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加银行卡</title>
    <link type="text/css" href="/css/finance.css" rel="stylesheet" />
    <link type="text/css" href="/css/common.css" rel="stylesheet" />
    <style type="text/css">
        .select-pic {
            position: absolute;
            z-index: 1000;
            width: 52px;
            height: 38px;
            left: 130px;
            top: 23px;
            background: url(/images/fw-select-add.png) no-repeat;
            display: none;
        }

        .btnhide {
            display: none;
        }
    </style>
    <script src="/jQuery/jquery-1.8.3.min.js"></script>
    <script src="/jQuery/Common.js"></script>
    <script type="text/javascript">

        $(function () {
            SearchAllBankInfor();
            $(".otherlist").hide();
        });

        function CheckCodeShow() {
            $("#div_ErrorInfor").html("短信验证码不正确或已过期");
            $("#div_ErrorInfor").show();
        }

        function CheckCodeHide() {
            $("#div_ErrorInfor").hide();
        }

        function CheckForAdd() {
            var OpenAccountAddress = $("#txt_OpenAccountAddress").val();
            var AccountBranch = $("#txt_AccountBranch").val();
            var BankCardNo = $("#txt_BankCardNo").val();
            var ReservePhonenumber = $("#txt_ReservePhonenumber").val();
            var banktype = $("#span_bankid").val();
            var IsDefaultCard = $("#txt_IsDefaultCard").attr("checked");
            var smscode = $("#txt_smscode").val();
            if (IsDefaultCard == "checked") {
                IsDefaultCard = "1";
            }
            else {
                IsDefaultCard = "0";
            }
            if (banktype == "") {
                $("#div_ErrorInfor").html("请选择银行卡");
                $("#div_ErrorInfor").show();
            }
            else if (OpenAccountAddress == "") {
                $("#div_ErrorInfor").html("请填写开户行所在地");
                $("#div_ErrorInfor").show();
            }
            else if (AccountBranch == "") {
                $("#div_ErrorInfor").html("请填写开户支行");
                $("#div_ErrorInfor").show();
            }
            else if (BankCardNo == "") {
                $("#div_ErrorInfor").html("请填写银行卡号");
                $("#div_ErrorInfor").show();
            }
            else if (!checkBankCardNo(BankCardNo)) {
                $("#div_ErrorInfor").html("请填写正确的银行卡号");
                $("#div_ErrorInfor").show();
            }
            else if (ReservePhonenumber == "") {
                $("#div_ErrorInfor").hide();
            }
            else if (!checkMobilePhone(ReservePhonenumber)) {
                $("#div_ErrorInfor").html("请填写正确的手机号码");
                $("#div_ErrorInfor").show();
            }
            else if (smscode == "") {
                $("#div_ErrorInfor").hide();
            }
            else {
                $.post("FinanceHandler.ashx?action=CheckCode", { "smscode": smscode }, function (data, status) {
                    if (data == "1") {
                        $("#div_ErrorInfor").hide();
                    }
                    else {
                        $("#div_ErrorInfor").html("短信验证码不正确或已过期");
                        $("#div_ErrorInfor").show();
                    }
                });
            }
        }

        function CheckForAdd1() {
            var OpenAccountAddress = $("#txt_OpenAccountAddress").val();
            var AccountBranch = $("#txt_AccountBranch").val();
            var BankCardNo = $("#txt_BankCardNo").val();
            var ReservePhonenumber = $("#txt_ReservePhonenumber").val();
            var banktype = $("#span_bankid").val();
            var IsDefaultCard = $("#txt_IsDefaultCard").attr("checked");
            var smscode = $("#txt_smscode").val();
            if (IsDefaultCard == "checked") {
                IsDefaultCard = "1";
            }
            else {
                IsDefaultCard = "0";
            }
            if (banktype == "") {
                $("#div_ErrorInfor").html("请选择银行卡");
                $("#div_ErrorInfor").show();
            }
            else if (OpenAccountAddress == "") {
                $("#div_ErrorInfor").html("请填写开户行所在地");
                $("#div_ErrorInfor").show();
            }
            else if (AccountBranch == "") {
                $("#div_ErrorInfor").html("请填写开户支行");
                $("#div_ErrorInfor").show();
            }
            else if (BankCardNo == "") {
                $("#div_ErrorInfor").html("请填写银行卡号");
                $("#div_ErrorInfor").show();
            }
            else if (!checkBankCardNo(BankCardNo)) {
                $("#div_ErrorInfor").html("请填写正确的银行卡号");
                $("#div_ErrorInfor").show();
            }
            else if (ReservePhonenumber == "") {
                $("#div_ErrorInfor").hide();
            }
            else if (!checkMobilePhone(ReservePhonenumber)) {
                $("#div_ErrorInfor").html("请填写正确的手机号码");
                $("#div_ErrorInfor").show();
            }
            else if (smscode == "") {
                $("#div_ErrorInfor").hide();
            }
            else {
                $.post("FinanceHandler.ashx?action=CheckCode", { "smscode": smscode }, function (data, status) {
                    if (data == "1") {
                        $("#div_ErrorInfor").hide();
                        document.getElementById('LinkButton1').click();
                    }
                    else {
                        $("#div_ErrorInfor").html("短信验证码不正确或已过期");
                        $("#div_ErrorInfor").show();
                    }
                });
            }
        }

        function Countdown() {
            //倒计时
            var timevalue = $(".yzm-notclick").html();
            var length = timevalue.length;
            var valuenumber = "";
            if (length == 8) {
                //两位数字
                valuenumber = timevalue.substring(0, 2);
            }
            else {
                //一位数字
                valuenumber = timevalue.substring(0, 1);
            }
            valuenumber = valuenumber - 1;
            var fontvalue = valuenumber + "s后重新获取";
            if (valuenumber < 0) {
                clearInterval(SecondCode);
                $(".yzm-notclick").hide();
                $(".yzm-click").show();
            }
            else {
                $(".yzm-notclick").html(fontvalue);
            }
        }

        var SecondCode = "";

        function SendSMSCode() {
            var OpenAccountAddress = $("#txt_OpenAccountAddress").val();
            var AccountBranch = $("#txt_AccountBranch").val();
            var BankCardNo = $("#txt_BankCardNo").val();
            var ReservePhonenumber = $("#txt_ReservePhonenumber").val();
            var banktype = $("#span_bankid").val();
            if (banktype == "") {

            }
            else if (OpenAccountAddress == "") {
            }
            else if (AccountBranch == "") {
            }
            else if (BankCardNo == "") {
            }
            else if (!checkBankCardNo(BankCardNo)) {
            }
            else if (!checkMobilePhone(ReservePhonenumber)) {
            }
            else {
                $(".yzm-notclick").html("60s后重新获取");
                $(".yzm-notclick").show();
                $(".yzm-click").hide();
                $.post("../FinanceHandler.ashx?action=SendSMSCode", { "phonenumber": ReservePhonenumber }, function (data, status) {
                    if (status == "success") {
                        if (data.length > 6) {
                            $("#div_ErrorInfor").html("获取短信验证码失败，请重新获取");
                            $("#div_ErrorInfor").show();
                        }
                        else {
                            $("#div_ErrorInfor").hide();
                            $("#span_code").html(data);
                        }
                    }
                });
                SecondCode = window.setInterval("Countdown()", 1000);
            }
        }

        function SearchAllBankInfor() {
            $.post("FinanceHandler.ashx?action=SearchAllBank", function (data, status) {
                if (status == "success") {
                    var infor = JSON.parse(data);
                    var htmlstring = "";
                    var htmlstr = "";
                    for (var i = 0; i < infor.length; i++) {
                        if (i <= 11) {
                            htmlstring += "<dd style='position:relative;' id=" + infor[i].ID + "_" + infor[i].DataName + " onclick='ChooseBankCard(this);' ><a href='javascript:;' >";
                            htmlstring += "<div id='select_" + infor[i].ID + "' class='select-pic'></div><img src=" + infor[i].DataIcon.replace("..","") + " />";
                            htmlstring += " </a></dd>";
                        }
                        else {
                            htmlstr += "<dd style='position:relative;' id=" + infor[i].ID + "_" + infor[i].DataName + " onclick='ChooseBankCard(this);' ><a href='javascript:;' >";
                            htmlstr += "<div id='select_" + infor[i].ID + "' class='select-pic'></div><img src=" + infor[i].DataIcon.replace("..", "") + " />";
                            htmlstr += " </a></dd>";
                        }
                    }
                    $("#dl_list").html(htmlstring);
                    $("#dl_otherlist").html(htmlstr);
                }
            });
        }

        function ChooseBankCard(i) {
            var bankid = i.id.toString().split('_')[0];
            var bankName = i.id.toString().split('_')[1];
            $("#span_bankid").val(bankid);
            $("#span_bankName").val(bankName);
            var PID = $(i).parent().attr("id");
            if (PID == "dl_list") {
                $("#select_" + bankid).show();
                $(i).children().css("border-color", "red");
                $($(i).siblings()).children().find("div").css("display", "none");
                $($(i).siblings()).children().css("border-color", "#ccc");
                $("#dl_otherlist").children().children().css("border-color", "#ccc");
                $("#dl_otherlist dd a div").css("display", "none");
            }
            else {
                $("#select_" + bankid).show();
                $(i).children().css("border-color", "red");
                $($(i).siblings()).children().css("border-color", "#ccc");
                $($(i).siblings()).children().find("div").css("display", "none");
                $("#dl_list dd a").css("border-color", "#ccc");
                $("#dl_list dd a div").css("display", "none");
            }
        }

        function ShowOtherBank() {
            var divclass = $("#div_otherbank").attr("class");
            if (divclass == "otherbank") {
                var divclass = $("#div_otherbank").attr("class", "otherbank otherbank-hover");
                $(".otherlist").hide();
            }
            else {
                var divclass = $("#div_otherbank").attr("class", "otherbank");
                $(".otherlist").show();
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="span_bankid" runat="server" />
        <asp:HiddenField ID="span_bankName" runat="server" />
        <!--content begin-->
        <div class="wrap jy-bg">
            <div class="trade-bt w1120 clearfix">
            
                <div class="trade-tit"><a href="#" class="cur">管理银行卡</a></div>
            </div>
        </div>
        <!--添加银行卡-->
        <div class="add-con">
            <div class="add-position">您所在的位置：银行账号 > <a href="#" class="blue">添加银行卡</a></div>
            <h1>添加银行卡</h1>
            <div class="add-step step2"></div>
            <div class="add-box2">
                <ul>
                    <li>
                        <div class="xg-left">真实姓名：</div>
                        <div class="xg-right">
                            <p>
                                <asp:TextBox ID="txt_name" runat="server" Enabled="false" class="add-input disabled"></asp:TextBox>
                            </p>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left">身份证号：</div>
                        <div class="xg-right">
                            <p>
                                <asp:TextBox ID="txt_Id" runat="server" Enabled="false" class="add-input disabled"></asp:TextBox>
                            </p>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>选择银行卡：</div>
                        <div class="xg-right">
                            <div class="banklist clearfix">
                                <dl id="dl_list" class="b-lb">
                                </dl>
                                <div id="div_otherbank" class="otherbank otherbank-hover">
                                    <a href="javascript:;" onclick="ShowOtherBank();" class="otherbtn">选择其他银行<i class="clickicon"></i></a>
                                    <div class="otherlist">
                                        <dl id="dl_otherlist" class="b-lb">
                                        </dl>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>开户行所在地：</div>
                        <div class="xg-right">
                            <asp:TextBox ID="txt_OpenAccountAddress" runat="server" class="add-input" Style="width: 700px;"></asp:TextBox>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>开户支行：</div>
                        <div class="xg-right">
                            <asp:TextBox ID="txt_AccountBranch" class="add-input" Style="width: 700px;" runat="server"></asp:TextBox>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>银行卡号：</div>
                        <div class="xg-right">
                            <p>
                                <asp:TextBox ID="txt_BankCardNo" runat="server" class="add-input"></asp:TextBox>
                            </p>
                            <p class="default-bankcard">
                                <asp:CheckBox ID="txt_IsDefaultCard" runat="server" class="default-xz" />
                                将此卡设为默认提现银行卡
                            </p>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>预留手机号：</div>
                        <div class="xg-right">
                            <p>
                                <asp:TextBox ID="txt_ReservePhonenumber" runat="server" class="add-input"></asp:TextBox>
                            </p>
                            <p class="r-tips1">请输入11位预留手机号</p>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left"><span class="red">*</span>短信验证码：</div>
                        <div class="xg-right">
                            <p>
                                <span>
                                    <input runat="server" id="txt_smscode" type="text" name="name" value="" class="add-input" style="width: 140px;" onblur="CheckForAdd();" />
                                </span><span><a href="javascript:;" class="yzm-click" onclick="SendSMSCode();">获取短信验证码</a><a href="javascript:;" class="yzm-notclick" style="display: none;">60s后重新获取</a></span>
                            </p>
                            <p class="r-tips1">请输入6位短信验证码</p>
                            <p id="div_ErrorInfor" class="r-tips2" style="display: none;">您输入的验证码有误</p>
                        </div>
                    </li>
                    <li>
                        <div class="xg-left">&nbsp;</div>
                        <div class="xg-right">
                            <a id="LinkButton2" class="next-submit" onclick="CheckForAdd1();">添加</a>
                            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" class="next-submit" CssClass="btnhide">添加</asp:LinkButton>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
        <!--content end-->
    </form>
</body>
</html>
